/**
 * author wen
 * cunyu
 * email wjd_13@hotmail.com
 */
package com.cunyu.service;

import com.cunyu.bean.Form;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 系统配置
 * @author win
 * 2019/04/29-11:22
 */
@Service
public class AppService extends BaseService{

    public List<Map<String, Object>> configs(){
        String sql = "select * from appconfig" ;
        return getList(sql) ;
    }

    public Map<String, Object> getConfig(int i) {
        String sql = "select * from appconfig where id = ? " ;
        return getMap(sql,i) ;
    }

    public void updateConfig(Form form) {
        String sql = "update appconfig set key = ? ,value = ?, des = ? ,type = ? where id = ? " ;
        exec(sql,form.getKey(),form.getValue(),form.getDes(),intV(form.getType()),
                intV(form.getId())) ;
    }

    public int newConfig(Form form) {
        String sql = "insert into appconfig (key,value,des,type) values (?,?,?,?)" ;
        return  insert(sql,form.getKey(),form.getValue(),form.getDes(),intV(form.getType())) ;
    }

    public void delConfig(int id) {
        String sql = "delete from appConfig where id = ? " ;
        exec(sql,id);
    }
}
